/**************************************************************************************
* ItemSlot.java
* 
* A place an item can be equipped
*************************************************************************************/
package creid.mythos.engine;

import java.io.Serializable;

public class ItemSlot implements Serializable
{

	//Constants/////////////////////////////////////////////////////////////////////////
	public static final int WIELD = -1;
	public static final int SWAP = -2;
	
	//Attributes////////////////////////////////////////////////////////////////////////
	
	private static final long serialVersionUID = -6012811014617318850L;

	private Item equipment;
	
	private int slotType;

	//Constructors//////////////////////////////////////////////////////////////////////
	//(int id, String singular, String plural, char[] sprite, int level, int rarity, int type, int power, int mass, String useVerb)
	
	public ItemSlot(int type)
	{
		slotType = type;
		equipment = null;
	}

	//Methods///////////////////////////////////////////////////////////////////////////

	public int getSlotType()
	{
		return slotType;
	}

	public void setSlotType(int slotType)
	{
		this.slotType = slotType;
	}

	public Item getEquipment()
	{
		return equipment;
	}

	public void setEquipment(Item equipment)
	{
		this.equipment = equipment;
	}
	
	public Item removeEquipment()
	{
		Item eq = equipment;
		equipment = null;
		return eq;
	}
	
	public boolean hasEquipment()
	{
		if (equipment == null)
			return false;
		else
			return true;
	}
	
	public boolean canEquip(Item item)
	{
		if (item == null)
			return true;
		
		if (item.getType() == slotType)
			return true;
		
		//Hand and offhand slots can hold weapons
		if ((item.getType() == Item.I_WEAPON || item.getType() == Item.I_GUN)
				&& (slotType == WIELD || slotType == SWAP))
			return true;
		
		return false;
	}
}
